# Copyright 2019 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Tests for common transforms.

load("//build_tools/bazel:enforce_glob.bzl", "enforce_glob")
load("//build_tools/bazel:iree_lit_test.bzl", "iree_lit_test_suite")

package(
    features = ["layering_check"],
    licenses = ["notice"],  # Apache 2.0
)

iree_lit_test_suite(
    name = "lit",
    srcs = enforce_glob(
        [
            "add_fmfs.mlir",
            "affinemin_canonicalization.mlir",
            "batch_matmuls.mlir",
            "bubble_up_ordinal_ops.mlir",
            "bufferize_copy_only_dispatches.mlir",
            "canonicalize_interface_load_store.mlir",
            "convert_bf16_to_uint16_buffers.mlir",
            "convert_bf16_arith_to_f32.mlir",
            "convert_to_destination_passing_style.mlir",
            "convolutions.mlir",
            "erase_dead_alloc_and_stores.mlir",
            "decompose_affine_ops.mlir",
            "decompose_batch_mmt4d_ops.mlir",
            "decompose_linalg_generic.mlir",
            "decompose_pack_unpack_ops.mlir",
            "decompose_softmax.mlir",
            "eliminate_empty_tensors.mlir",
            "emulate_narrow_type.mlir",
            "erase_hal_descriptor_type.mlir",
            "extract_address_computation.mlir",
            "flatten_memref_subspan.mlir",
            "fold_affine_min_in_distributed_loops.mlir",
            "fold_affine_min_of_block_id.mlir",
            "fold_tensor_extract_op.mlir",
            "forop_canonicalization.mlir",
            "generic_vectorization.mlir",
            "hoist_statically_bound_allocations.mlir",
            "hoist_unrolled_vector_extract_insert_slice.mlir",
            "iree_comprehensive_bufferize.mlir",
            "iree_expand_strided_metadata.mlir",
            "lower_ukernel_to_calls.mlir",
            "materialize_encoding_into_nop.mlir",
            "materialize_user_configs.mlir",
            "pad_dynamic_alloc.mlir",
            "polynomial_approximation.mlir",
            "reductions.mlir",
            "rematerialize_parallel_ops.mlir",
            "remove_dead_allocs.mlir",
            "remove_trivial_loops.mlir",
            "repeated_matcher_use.mlir",
            "replace_slow_min_max_ops.mlir",
            "test_partitionable_loops_interface.mlir",
            "tile_and_distribute_to_workgroups.mlir",
            "transform_buffer_opt.mlir",
            "transform_match_partial_reduction.mlir",
            "transform_ops_invalid.mlir",
            "transpose_canonicalization.mlir",
            "type_propagation.mlir",
            "type_propagation_packing.mlir",
            "vectorize_tensor_pad.mlir",
            "vector_layout_analysis.mlir",
            "workgroup_specialization.mlir",
        ],
        include = ["*.mlir"],
        exclude = [
            "batch_matmul_match_spec.mlir",
            "convolution_match_spec.mlir",
            "reductions_codegen_spec.mlir",
            "reductions_match_spec.mlir",
        ],
    ),
    cfg = "//compiler:lit.cfg.py",
    # transform dialect spec files are MLIR files that specify a transformation,
    # they need to be included as data.
    data = [
        "batch_matmul_match_spec.mlir",
        "convolution_match_spec.mlir",
        "reductions_codegen_spec.mlir",
        "reductions_match_spec.mlir",
    ],
    tools = [
        "//tools:iree-opt",
        "@llvm-project//llvm:FileCheck",
    ],
)
